package a2;

/**
 * File is a class that represents a single File on a virtual {@link FileSystem}
 * . It has a {@link String} that stores the content of this File. Handles the
 * "cat" bash command.
 * 
 * @author Dylan Seago, Tianran Liu, Hilal Dib, Paschal Oduoza
 */
public class File extends Item {

	/**
	 * {@link String} that contains the text within this {@link File}.
	 */
	private String content;

	/**
	 * Initializes a new {@link File} with a given {@code name}, {@code content}
	 * , and {@code parent} {@link Directory}.
	 * 
	 * @param name
	 *            Name of this {@link File}.
	 * @param content
	 *            Content of this {@link File}.
	 * @param parent
	 *            {@link Directory} that contains this {@link File}.
	 */
	public File(String name, String content, Directory parent) {
		super(name, parent);
		this.content = content;
	}

	/**
	 * Gets the content of this file as a {@link String}.
	 * 
	 * @return Content of this file as a {@link String}.
	 */
	public String getContent() {
		return content;
	}

	/**
	 * Sets the {@link String} content of this {@link File}.
	 * 
	 * @param content
	 *            {@link String} to set the content of this {@link File} to.
	 * @return This {@link File}.
	 */
	public File setContent(String content) {
		this.content = content;
		return this;
	}
	
	public File appendContent(String content) {
		this.content = this.content + content;
		return this;
	}

	/**
	 * Prints out this files content.
	 */
	public String cat() {
		return content;
	}
	
	
	
}
